C = ply-image.c \
    ply-frame-buffer.c \
    ply-gamma.c \
    ply-kms.c \
    ply-list.c \
    ply-monitor.c

H = ply-frame-buffer.h \
    ply-gamma.h \
    ply-kms.h \
    ply-list.h \
    ply-monitor.h \
    ply-utils.h

SRC ?= .
OUT ?= .
VPATH = $(SRC)

CFLAGS ?= -O2
CFLAGS += -Wall
PKG_CONFIG ?= pkg-config
CPPFLAGS += -I$(SRC)

all: $(OUT)/ply-image

$(OUT)/ply-image: $(C) $(H) Makefile
	$(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) $(C) -o $@ \
		-lpng -lrt -lm `$(PKG_CONFIG) --libs --cflags libdrm`

clean:
	rm -f ply-image *~
